1 package com.inigoserrano.isvalidator.data;
2
3 import com.inigoserrano.isvalidator.dataGroup.CommandLineDataGroup;
4 import com.inigoserrano.isvalidator.errorDo.ErrorDo;
5
6 /***
7 * This constraintContainer is designed to contain one argument from the
8 * command line (or and array of strings)
9 * @license@
10 * @version @version@
11 * @author @author@
12 **/
13 public class CommandLineArgumentData extends SimpleData {
14 /***
15 * the array string
16 */
17 protected String[] args;
18 /***
19 * the position of the data in the array string
20 */
21 protected int position;
22
23 /***
24 * Constructor. This constructor dosnīt add this object to the
25 * metacontainer.
26 * @param position the position of the argument in the array of strings
27 * @param argumentName the name of the argument (data),
28 * for example: src, dest, email,... it is used to look for it in the
29 * metacontainer
30 * @param args the array of strings with all the data
31 **/
32 public CommandLineArgumentData(
33 int position,
34 String argumentName,
35 String[] args) {
36 super(args[position], argumentName);
37 this.args = args;
38 this.position = position;
39 }
40
41 /***
42 * Constructor. This constructor dosenīt add this object
43 * to the metacontainer.
44 * @param position the position of the argument in the array of strings
45 * @param argumentName the name of the argument (data),
46 * for example: src, dest, email,... it is used to look for
47 * it in the metacontainer
48 * @param args the array of strings with all the data
49 * @param throwException if must throw an exception if the data
50 * is not valid.
51 **/
52 public CommandLineArgumentData(
53 int position,
54 String argumentName,
55 String[] args,
56 boolean throwException) {
57 super(args[position], argumentName, throwException);
58 this.args = args;
59 this.position = position;
60 this.throwException = throwException;
61 }
62
63 /***
64 * Constructor. Looks for the array of strings in the metacontainer,
65 * and add this object to the metacontainer.
66 * @param position the position of the argument in the array of strings
67 * @param argumentName the name of the argument (data),
68 * for example: src, dest, email,... it is used to look for
69 * it in the metacontainer
70 * @param dataGroup the DataGroup in with the Data is grouped.
71 **/
72 public CommandLineArgumentData(
73 int position,
74 String argumentName,
75 CommandLineDataGroup dataGroup) {
76 super(dataGroup.getAllArguments()[position], argumentName);
77 this.args = dataGroup.getAllArguments();
78 this.position = position;
79 dataGroup.addData(this);
80 }
81
82 /***
83 * Constructor. Looks for the array of strings in the metacontainer,
84 * and add this object to the metacontainer.
85 * @param position the position of the argument in the array of strings
86 * @param argumentName the name of the argument (data),
87 * for example: src, dest, email,... it is used to look for
88 * it in the metacontainer
89 * @param dataGroup the DataGroup in with the Data is grouped.
90 * @param throwException if must throw an exception if the data
91 * is not valid.
92 **/
93 public CommandLineArgumentData(
94 int position,
95 String argumentName,
96 CommandLineDataGroup dataGroup,
97 boolean throwException) {
98 super(dataGroup.getAllArguments()[position], argumentName);
99 this.args = dataGroup.getAllArguments();
100 this.position = position;
101 this.throwException = throwException;
102 dataGroup.addData(this);
103 }
104
105 /***
106 * add the parameters of the constraint container
107 * @param listener the listener of the parameters to add
108 **/
109 public void addDataParameters(ErrorDo listener) {
110 listener.addParameter("argumentName", valueToCheckName);
111 }
112
113 /***
114 * Alias for the getValueToCheckName, to be more easy
115 * @return the valueToCheckName
116 **/
117 public String getArgumentName() {
118 return getValueToCheckName();
119 }
120 }
This page was automatically generated by Maven